<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://"
            + request.getServerName() + ":" + request.getServerPort()
            + path + "/";
%>
<style>
    div.goodsBox{
        margin-bottom: 10px;
        background-color: #fff;
        padding: 1rem;
    }
    div.goodsBox:after{ display: block; content: ''; clear: both; }
    div.content-list-wrap .inner-list{
        background-color: transparent;
    }
    div.goods_title p{
        font-size: 1.4rem;
        color: #000;
    }
    input.payBtn{
        float: right;
    }
    .money{
        font-size: 1.7rem;
        color: #e78f08;
        font-weight: bold;
    }
    .small{
        font-size: 1rem;
    }
    .payBtn{
        font-size: 14px;
        background: rgba(0, 0, 0, 0.3);
        padding: 0 15px 0 15px;
        position: relative;
        color: #FFFFFF;
        box-shadow: 0 0 0 #fff, 0 0 1px #fff, 0 0 1px #fff;
        border-radius: 15px;
        float: right;
        line-height: 28px;
    }
    .unpay{
        background:rgba(255, 0, 0, 0.6);
    }
</style>
<link rel="stylesheet" type="text/css" href="<%=basePath%>/app/plugins/dialog/css/dialog.css" />
<div id="pay_info">
    <script type="text/html" id="tpl-pay">
        <input type="hidden" id="id" name="id" value="{{resultList.busi_id}}">
        <input type="hidden" id="orderId" name="orderId" value="{{resultList.id}}">
            <div class="content-list-wrap">
                <div class="mui-content mui-scroll-wrapper" id="contentListWrap">
                    <div class="mui-scroll">
                        <div class="inner-list">
                            <div class="content-top-banner">
                                <div class="mui-slider" id="muiSlideList">
                                    <div class="mui-slider-group">
                                        {{each parseJson(resultList.busi_img) as value i}}
                                        <div class="mui-slider-item">
                                            <a class="thumb"><img src="{{value.img}}"/></a>
                                        </div>
                                        {{/each}}
                                    </div>
                                    <div class="mui-slider-indicator">
                                        {{each parseJson(resultList.busi_img) as value i}}
                                        <div class="mui-indicator {{if i==0}}mui-active{{/if}}"></div>
                                        {{/each}}
                                    </div>
                                </div>
                            </div>
                            <div class="goodsBox goods_title">
                                <p>{{resultList.busi_name}}</p>
                            </div>
                            <div class="goodsBox" style="line-height: 28px">
                                {{orderStatus resultList.status}}
                                <p style="font-size: 1.3rem;color: #000">
                                    实付：<span class="money small">￥</span>
                                    <span class="money">{{dealAmount resultList.price}}</span>
                                </p>
                            </div>
                            <div class="goodsBox">
                                <p>订单编号：<span style="color: #000">{{resultList.order_num}}</span></p>
                                <p>下单日期：<span style="color: #000">{{formatTime resultList.create_time}}</span></p>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
    </script>
</div>
<script type="text/javascript" src="<%=basePath%>/app/js/wxShare.js"></script>
<script type="text/javascript" src="<%=basePath%>/app/js/wechat.js"></script>
<script type="text/javascript" src="<%=basePath%>/app/plugins/dialog/js/dialog.js"></script>
<script>
    $(function () {
        $.ajax({
            url: _basePath + "app/order/get",
            data:{id:${orderId}},
            dataType: 'json',
            success: function (data) {
                if(typeof data.resultList != undefined && data.resCode == 0){
                    $("#pay_info").append(template('tpl-pay', data));
                    mui('#muiSlideList').slider();
                }else{
                    mui.toast(data['message']);
                }
            }
        });

        mui('body').on('tap', "div.unpay", function () {
            //提示是否支付
            /*var btnArray = ['我在想想','去支付'];
            mui.confirm('点击"去支付"前往微信进行支付', '确认支付?', btnArray, function(e){
                if (e.index == 1) {
                    //打开新页面
                    wechatPay($("#orderId").val(),location.href,function(){
                        setTimeout(function(){
                            mui.openWindow({
                                url:_basePath + "app/page/info_detail?id="+$("#id").val()
                            })
                        },1000)
                    });
                }
            });*/
            $.dialog({
                titleText : '确认支付?',
                type : 'confirm',
                buttonText : {
                    ok : '去支付',
                    cancel : '我再想想'
                },
                onClickOk : function(){
                    //打开新页面
                    wechatPay($("#orderId").val(),location.href,function(){
                        setTimeout(function(){
                            mui.openWindow({
                                url:_basePath + "app/page/info_detail?id="+$("#id").val()
                            })
                        },1000)
                    });
                },
                onClickCancel : function(){
                    return true;
                },
                contentHtml : '点击"去支付"前往微信进行支付'
            });
        });
    })
</script>